<?php
namespace Auth;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;

/*---------------------Import Auth Model----------------------------*/
use Auth\Model\Auth;                                             
use Auth\Model\UsersTable;
use Auth\Model\UsersMapper;
/*---------------------Import Auth Model----------------------------*/
class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
    
    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'Auth\Model\UsersTable' => function($sm){
                    $tableGateway = $sm->get('UsersTableGateway');
                    $table = new UsersTable($tableGateway);
                    return $table;
                },
                'UsersTableGateway' => function($sm){
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Auth());
                    return new TableGateway('users' , $dbAdapter , null , $resultSetPrototype);
                },
                
                'UsersMapper' => function($sm){
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $mapper = new UsersMapper($dbAdapter);
                    return $mapper;
                }
            ),
        );
    }
}
